package com.lishao.system.utils;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.lishao.system.DateJsonValueProcessor;

import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

public class ActionUtil {
	public final void writeMap(Map result) throws Exception{
		JsonConfig cfg = new JsonConfig();  
		cfg.registerJsonValueProcessor(java.sql.Date.class, new DateJsonValueProcessor());
		cfg.registerJsonValueProcessor(java.sql.Timestamp.class, new DateJsonValueProcessor());
		cfg.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor());
		JSONObject jsonObject = JSONObject.fromObject(result,cfg);
		System.out.println(jsonObject.toString());
		HttpServletResponse response = ServletActionContext.getResponse();
		response.getWriter().write(jsonObject.toString());
	}
}
